package com.baizhi.controller;


import com.baizhi.entity.PmsAttrGroup;
import com.baizhi.service.IPmsAttrGroupService;
import com.baizhi.vo.PmsAttrGroupVo;
import com.baizhi.vo.R;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 属性分组 前端控制器
 * </p>
 *
 * @author xhc
 * @since 2020-09-29
 */
@RestController
@RequestMapping("attr-group")
public class PmsAttrGroupController {
    @Autowired
    private IPmsAttrGroupService attrGroupService;

    @GetMapping("selectAttrGroupBySizeAndCateId")
    public R selectAttrGroupBySizeAndCateId(Integer page, Integer limit, Long categoryId){
        Page<PmsAttrGroup> attrGroupPage = attrGroupService.page(
                new Page<>(page, limit),
                new QueryWrapper<PmsAttrGroup>().eq("category_id",categoryId)
        );
        return R.ok().put("count",attrGroupPage.getTotal()).put("data",attrGroupPage.getRecords());
    }


    @GetMapping("addAttrGroup")
    public  R savePmsAttrGroup(PmsAttrGroupVo pmsAttrGroupVo){
        System.out.println(pmsAttrGroupVo);
            attrGroupService.savePmsAttrGroup(pmsAttrGroupVo);
            return R.ok();


    }


}
